cap log close
log using "${logpath}recoveries.log", replace

/*******************************************************************************
recoveries.do

This code reports statistics on recoveries from criminal and civil cases
*******************************************************************************/

*Importing recovery data
import excel "${rawdatapath}RecoveryData_full.xlsx", sheet("Sheet1") firstrow clear
drop if missing(TotalPaidRecoveredtoDate)

*Getting total paid
su TotalPaidRecoveredtoDate // Referenced in Section 6.1, Paragraph 2 and Appendix J.2, Bullet 1

*Getting share of total paid
egen TotalPaid=total(TotalPaidRecoveredtoDate)
egen TotalOwed=total(TotalAmountPaidOwed)
gen TotalPaidShare=TotalPaid/TotalOwed
list TotalPaidShare if _n==1 // Referenced in Section 6.1, Paragraph 2 and Appendix J.2, Bullet 1

*Getting stats on partial/full payments
gen fullpaid=TotalPaidRecoveredtoDate==TotalAmountPaidOwed
tab fullpaid // Referenced in Section 6.1, Paragraph 2 and Appendix J.2, Bullet 1

gen less20=TotalPaidRecoveredtoDate/TotalAmountPaidOwed<0.2
tab less20 // Referenced in Section 6.1, Paragraph 2 and Appendix J.2, Bullet 1

*Getting median close year
destring CaseClosedYear, replace force
replace CaseClosedYear=2024 if missing(CaseClosedYear)
su CaseClosedYear, d // Referenced in Section 6.1, Paragraph 2

log close